﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Xml;
using System.Net;
using System.Threading;
using System.Windows;

namespace ValuationLogic
{
    class Settlement
    {



        internal static Hashtable priceTable = new Hashtable();



        public static void init()
        {
            //refreshData();
            /*List< List<double>> priceList = new List< List<double>>();
            for (int month = 0; month <= 12; month++)
            {
                List<double> monthList = new List<double>();
                for (int day = 0; day <= 31; day++)
                    //monthList.Add(month * 100 + day);
                    monthList.Add((double)80);
                priceList.Add(monthList);
            }
            if (priceTable[2013] == null)
                priceTable.Add(2013, priceList);*/
        }

        /// <summary>
        /// Get the sum from the date to the end of the month of the date
        /// </summary>
        /// <param name="date"></param>
        /// <returns></returns>
        internal static double getSettlementPriceSum(DateTime date)
        {
            return getSettlementPriceSum(date, SwapDate.getDaysofMonth(date) - date.Day + 1);
        }

        internal static double getSettlementPriceSum(DateTime date, int period)
        {
            //refreshData();
            double rtn = 0;
            for (int i = 0; i < period; i++)
            {
                if (date.DayOfWeek.ToString()[0] != 'S')
                {
                    int int_date = date.Year * 10000 + date.Month * 100 + date.Day;
                    if (priceTable[int_date] != null)
                        rtn += (double)priceTable[int_date];
                    else
                        throw new Exception("Don't have enough data to calculate!");
                }
                date = date.AddDays(1);
            }
            return rtn;
        }




    }
}
